<?php

namespace app\controller;
use app\model\BorrowRecordLibBookBookIntroBookTypeLibraryClassifyModel;
use think\annotation\route;
use think\facade\Db;
use think\response\Json;

class BorrowRecordLibBookBookIntroBookTypeLibraryClassifyController
{
    /**
     * @route ("getAllBorrowRecordForUser")
     * @return Json
     */
    public function getAllBorrowRecordForUser($userId)
    {
        return json(Db::table("BorrowRecord_LibBook_BookIntro_BookType_Library_Classify")
            ->where("readerId", $userId)
            ->select());
    }

    /**
     * @route ("getAllBorrowRecordForAdmin")
     * @param $libraryId
     * @return Json
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getAllBorrowRecordForAdmin($libraryId, BorrowRecordLibBookBookIntroBookTypeLibraryClassifyModel $had)
    {
        return json($had
            ->where("libraryId", $libraryId)
            ->select());
    }
}